<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css" />
		<style>
			
			.option>div
			{
				margin-bottom:5px;
			}
		</style>
	</head>

	<body>
		<div class="am-g">
		{include file='../Common/hy_header.html'}
			<div class="am-u-md-8 am-u-end">
				<form class="am-form am-form-horizontal hy-js-form">
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">标题</label>
						<div class="am-u-sm-9">
							<input type="text" name="name" value="{$vote.name}" placeholder=""  {if $vote.joinnums >0} readonly=true {/if} >
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">参与人数</label>
						<div class="am-u-sm-9">
							
							<input type="text" value="{$vote.joinnums|default:0}" name="joinnums"  readonly=true >
						</div>
					</div>
					
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">活动时间:</label>
						<div class="am-u-sm-9">
							
								<div class="am-u-md-6 am-cf " style="padding-left:0px;">
						        
						          <div class="am-input-group am-input-group-sm" style="width:100%">
						          		<input name="dotime1"  value="{$vote.dotime1}" data-am-datepicker type="text" class="am-form-field hy-js-search-type" placeholder="起始時間">
						          </div>
						        
						      </div>
							  <div class="am-u-md-6 am-cf " style="padding-left:0px;padding-right:0" >
						        
						          <div class="am-input-group am-input-group-sm"  style="width:100%">
						          		<input name="dotime2" value="{$vote.dotime2}" data-am-datepicker type="text" class="am-form-field hy-js-search-type" placeholder="截止時間">
						          </div>
						        
						      </div>
	  					</div>
					</div>
					
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">选项:</label>
						<div class="am-u-sm-9">
							
							{if $vote.option}
							{foreach  from=$vote.option item=option  name=option }
							
							
							
							<div id="option{$option.id}" class="option" >
							<div class="am-u-sm-8" style="padding-left:0px">
								<input type="text" value="{$option.name}" name="option_name[]"  {if $vote.joinnums >0} disabled=true {/if}  >
							</div>
							
							<label  class="am-u-sm-2 am-form-label">{$option.playnums}票</label>
							{if $vote.joinnums ==0} 
							{if $smarty.foreach.option.index ==0}
            				
							<div class="am-u-sm-2 " >
								<div class="am-btn-toolbar " style="display:inline-block;">
            <div class="am-btn-group am-btn-group-xs">
              <button  onclick="addInput()"  type="button" class="am-btn am-btn-default "><span class="am-icon-plus"></span> 添加</button>
            </div>

           
          </div>
		  

							</div>
							
							{else}
							
							<div class="am-u-sm-2 " >
								<div class="am-btn-toolbar " style="display:inline-block;">
            <div class="am-btn-group am-btn-group-xs">
              <button  onclick="delInput('option{$option.id}')"  type="button" class="am-btn am-btn-default "><span class="am-icon-trash-o"></span> 删除</button>
            </div>

           
          </div>
		  

							</div>
						
						
							
							{/if}
							{/if}
							</div>
							{/foreach}
							</div>
							{else}
							<div id="option0" class="option">
							<div class="am-u-sm-8" style="padding-left:0px">
								<input type="text" value="" name="option_name[]"  >
							</div>
							
								<label  class="am-u-sm-2 am-form-label">0票</label>
							
								<div class="am-u-sm-2 " >
								<div class="am-btn-toolbar " style="display:inline-block;">
            <div class="am-btn-group am-btn-group-xs">
              <button   onclick="addInput()"  type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 添加</button>
            </div>

           
          </div>
		  

							</div>

							</div>
							{/if}
						</div>
					
					
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">状态:</label>
					<div class="am-u-sm-9">
							<div class="am-btn-group" data-am-button="">
								<label class="am-btn am-btn-default am-btn-xs  {if $vote.status eq 0} am-active  {/if}">
									<input type="radio" name="status" value="0" {if $vote.status eq 0} checked="checked" {/if} id="option1"> 结束
								</label>
								<label class="am-btn am-btn-default am-btn-xs  {if $vote.status eq 1} am-active  {/if}">
									<input type="radio" name="status" {if $vote.status eq 1} checked="checked" {else}{/if} value="1" id="option2">开启
								</label>
							</div>
						</div>
					</div>	
						
					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-push-3">
							<input type="hidden" value="{$vote.id}" name="id">
							<button type="button" class="am-btn am-btn-primary hy-js-submit">{$_L.SAVE}</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		{include file='../Common/hy_footer.html'}
		<script type="text/javascript">
			 hy_submit('index.php?g=admin&m=vote&a=updateVote');
			 
			 
			 var num = 99999;
	
	function addInput()
		{
			
//			<div id="option0" class="option">
//							<div class="am-u-sm-8" style="padding-left:0px">
//								<input type="text" value="" name="option_name[]"  >
//							</div>
//							
//								<label  class="am-u-sm-2 am-form-label">0票</label>
//							
//								<div class="am-u-sm-2 " >
//								<div class="am-btn-toolbar " style="display:inline-block;">
//            <div class="am-btn-group am-btn-group-xs">
//              <button   onclick="addInput()"  type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 添加</button>
//            </div>
//
//           
//          </div>
//		  
//
//							</div>
//
//							</div>
			num++;
			
							var str='<div id="option'+num+'" class="option">'
								+'<div class="am-u-sm-8" style="padding-left:0px">'
								+'<input type="text" value="" name="option_name[]"  >'
								+'</div><label  class="am-u-sm-2 am-form-label">0票</label>'
								
								+'<div class="am-u-sm-2 " >'
								+'<div class="am-btn-toolbar " style="display:inline-block;">'
					            +'<div class="am-btn-group am-btn-group-xs">'
					            +'<button   onclick="delInput(\'option'+num+'\')"  type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>'
					            +'</div>'
								+'</div>'
		  						+'</div>';
//								+'<span  style="line-height:35px;" onclick="delInput(\'option'+num+'\')">&nbsp;&nbsp;&nbsp;-'
//	            				+'</span>'
//								+'</div>'
//								+'</div>';
							
         	
			$(str).insertAfter(".option:last-child");
//			alert(str);
			
		}
		
		
		function delInput(id)
		{
			$("#"+id).html("").hide();
		}
		
		</script>
	</body>

</html>